package com.github.chirspan.xaas.uc.service.impl;

import com.github.chirspan.xaas.uc.dao.OrgOrganizationDao;
import com.github.chirspan.xaas.uc.model.OrgOrganization;
import com.github.chirspan.xaas.bo.OrgAndDeptBo;
import com.github.chirspan.xaas.mybatis.service.impl.BaseServiceImpl;
import com.github.chirspan.xaas.mybatis.util.tree.TreeUtils;
import com.github.chirspan.xaas.uc.service.IOrgOrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: chenpan
 * @Date: 2021-08-10 11:03:10
 * @Description: 机构信息 接口实现
 */
@Service
public class OrgOrganizationServiceImpl extends BaseServiceImpl<OrgOrganizationDao, OrgOrganization> implements IOrgOrganizationService {

    @Autowired
    private OrgOrganizationDao orgDao;

    @Override
    public List<OrgAndDeptBo> getOrgAndDeptTree(OrgAndDeptBo bo, boolean isAbleOrg) {
        List<OrgAndDeptBo> list = orgDao.selectOrgAndDept(bo, isAbleOrg);
        return TreeUtils.buildTree(list);
    }

    @Override
    public List<OrgOrganization> getOrgTree(OrgOrganization organization) {
        List<OrgOrganization> organizations = super.list();
        return TreeUtils.buildTree(organizations);
    }
}
